<template>
	<view>
		        <view class="uni-padding-wrap" style="margin-bottom: 20rpx;">
		            <view class="page-section swiper">
		                <view class="page-section-spacing">
		                    <swiper class="swiper" :indicator-dots="indicatorDots" :autoplay="autoplay"  :current="currentTab">
		                        <swiper-item v-for="image in currentSchool.images" >
		                            <view ><image :src="image" style="width: 750rpx;"/></view>
		                        </swiper-item>
		                    </swiper>
		                </view>
		            </view>
		        </view>
				
				<view>
					<text style="float: left;margin-right: 50rpx;">xx学校</text>
					<input style="background: #999999;width: 375rpx;float: left;" v-model="inputSchoolName" />
					<button size="mini" v-on:click="changeByName" style="float: left;">切换</button>
				</view>
				<view style="background: url(../../static/C4206E4BD992AFD1E3BF56019CE39487.jpg);margin-top: 100rpx;border-radius:20px 20px 20px;width: 700rpx;margin-left: 25rpx;">
					<text>
						&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;.\n
						&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<text style="font-size: 35px;margin-left: 100rpx;">{{currentSchool.name}}</text>\n
					    &nbsp;&nbsp;&nbsp;&nbsp&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{{currentSchool.details}}\n
					    &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;校训:{{currentSchool.motto}}\n
						&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;类别:{{currentSchool.type}}\n
						&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;创办时间:{{currentSchool.buildTime}}\n
						&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;地理位置:{{currentSchool.address}}\n
						.
					</text>
				</view>
				<text>\n \n \n </text>
				<view>
					<text v-for="(item,i) in currentSchool.schoolNotices" :key="i" @click="gotoDetails(item.message)">
						新闻/通知 {{i+1}} 
						<text style="color: #999999;">——————————————————————————————</text>\n
						
					</text>
				</view>
	</view>
</template>

<script>
	export default {
		 data() {
		        return {
		            indicatorDots: true,
		            autoplay: false,
					schools: [],
					currentSchool:{schoolNotices:[]},
					inputSchoolName:"",
					currentTab:0
		        }
		    },
		onShow() {
            	//查询是否登录
            	if(uni.getStorageSync("user")==""){
            		uni.navigateTo({url:'../login/login'}); 
            	}
            	//查询学校信息以及学校通知
            	uni.request({
            	method:"GET",
            	url:this.requestUrl+"/ForeSchoolController/findAll",
            	success:response=>{
            		this.schools=response.data.rows;
            		this.currentSchool=this.schools[this.currentTab];
            	}	
            	})	
		},
		onPullDownRefresh(){
			setTimeout(()=>{
				uni.stopPullDownRefresh()
			},1000)
			this.refresh();
		}
		,
		methods: {
				changeByName(){
					for(var i=0;i<this.schools.length;i++){
						if(this.schools[i].name==this.inputSchoolName){
							this.currentSchool=this.schools[i];
							this.currentTab=i;
						}
					}
				},
				gotoDetails(msg){
					uni.setStorageSync("msgDetails",msg);
					uni.navigateTo({url:'../schoolMessageDetails/schoolMessageDetails'});
					
				}
		    }
	}
</script>

<style>

</style>
